#!/bin/sh

# clean up build directory, if it exists
if [ -d "build" ]
then
	rm -R build
fi

mkdir build


rm /tmp/*.applescript

HOME=`echo $HOME`
SCRIPTSMENU="$HOME/Library/Scripts/iTunes"

# make sure iTunes scripts directory exists
if [ ! -d $SCRIPTSMENU ]
then
	mkdir $SCRIPTSMENU
fi

# build everything in the etc directory
osacompile -o "build/Email YAML For Playlist.scpt" "src/etc/EmailYAMLForPlaylist.applescript"
cp "build/Email YAML For Playlist.scpt" $SCRIPTSMENU

osacompile -o "build/Make YAML For Playlist.scpt" "src/etc/MakeYAMLForPlaylist.applescript"
cp "build/Make YAML For Playlist.scpt" $SCRIPTSMENU

osacompile -o "build/YAMLTuneImporter.app" "src/etc/YAMLTuneImporter.applescript"

# copy the ruby tune importer script into the droplet so that its path doesn't need to be hard-coded
mkdir "build/YAMLTuneImporter.app/Contents/Resources/ruby"
cp "src/etc/yamltuneimporter.rb" "build/YAMLTuneImporter.app/Contents/Resources/ruby"

# build the mail rule
osacompile -o "build/yamltunesmail.scpt" "src/mailrule.applescript"


